
/**直接插入排序1
void direct_insertion_sort(int a[],int m,int num)
{
	int i,j,temp;
	for(i = 0;i<m;i++)
	{
		if(num > a[i]&&num < a[i+1])
		{
			temp = a[i+1];
			a[i+1] = num;
			for(j = m;j>i+1;j--)
			{
				a[j] = a[j-1];
			}
			a[i+2] = temp;
			printf("temp = %d   a[i+2] = %d\n",temp,a[i+2]);
		//	a[i+2] = temp;
		}	
	}

	for(i = 0;i < m+1;i++)
	{
		if(a[i]!=0)
		{
			printf("%d->",a[i]);
		}
	}
}


int main()
{
	int a[100] = {1,2,3,4,5,6,7,8,9,11,15,47,55};
	direct_insertion_sort(a,100,56);
}
***/
/**直接插入排序2
void direct_insertion_sort(int *s,int m)
{
	int i,j,k = 1,n;
	for(i = 2;i<=m;i++)//数组下标从2开始，s[0]监哨，s[1]无可比性
	{
		s[0] = s[i];//给监视哨赋值
		j = i-1;
		while(s[0] < s[j])
		{
			s[j+1] = s[j];
			j--;	//移向左边的一个未比较的数
		}
		s[j+1] = s[0];//在确定的位置插入s[i]
	}
}



int main()
{
	int a[11],i;
	printf("请输入10个数据:\n");
	for(i = 1;i < 11;i++)
	{
		scanf("%d",&a[i]);
	}
	printf("原始序列为:\n");
	for(i = 1;i < 11;i++)
	{
		printf("%d->",a[i]);
	}
	printf("\n");
	printf("a[0] = %d\n",a[0]);
	printf("\n");
	direct_insertion_sort(a,10);
	printf("排序后的序列为:\n");
	for(i = 1;i < 11;i++)
	{
		printf("%d->",a[i]);
	}
	printf("\n");
}
**/

/**一些常用的字符串函数
#include<stdio.h>
#include<string.h>

int main()
{
	char str1[] = "aahcello world!a";
	char str2[] = "chendunyunchendunyunchendunyun";
//	int result ;
	char *p,*q;
	q = str2;
//	char *str3;
	printf("strlen(str1) = %d\n",strlen(str1));
	printf("strlen(str2) = %d\n",strlen(str2));
	printf("str1 = %s\n",str1);
	printf("str2 = %s\n",str2);
//	strcpy(str1,str2);//原型：char *strcpy(char *dst, char const *src);
//	printf("str1 = %s\n",str1);
//	printf("str2 = %s\n",str2);
//	printf("str3 = %s\n",str3);
//	strncpy(str1,str2,12);//原型：char *strncpy(char *dst, char const *src, size_t len);
//	printf("str1 = %s\n",str1);
//	printf("str2 = %s\n",str2);
//	strcat(str1,str2);//原型：char *strcat(char *dst, char const *src);
//	printf("str1 = %s\n",str1);
//	printf("str2 = %s\n",str2);
//	strncat(str1,str2,10);//原型：char *strncat(char *dst, char const *src, size_t len);
//	printf("str1 = %s\n",str1);
//	printf("str2 = %s\n",str2);
/*	result = strcmp(str1,str2);//原型：int strcmp(char const *s1, char const *s2);
	printf("result = %d\n",result);
	if(result > 0)
	{
		printf("str1比str2字符串大\n");
	}
	else if(result == 0)
	{
		printf("str1和str2字符串大小一样\n");
	}
	else
	{
		printf("str1比str2字符串小\n");
	}
*/
/*
	result = strncmp(str1,str2,1);//原型：int strncmp(char const *s1, char const *s2, size_t len);
	printf("result = %d\n",result);
	if(result > 0)
	{
		printf("str1比str2字符串大\n");
	}
	else if(result == 0)
	{
		printf("str1和str2字符串大小一样\n");
	}
	else
	{
		printf("str1比str2字符串小\n");
	}
*/
/*
	p = strchr(str1,97);//char *strchr(char const *str, int ch);
	if(p == NULL)
	{
		printf("97不在字符串str1\n");
	}
	else
	printf("所查找的字符所在的地址为%p\n",p);

	p = strchr(str1,104);
	if(p == NULL)
	{
		printf("104不在字符串str1\n");
	}
	else
	printf("所查找的字符所在的地址为%p\n",p);

	p = strrchr(str1,97);//char *strrchr(char const *str, int ch);
	if(p == NULL)
	{
		printf("97不在字符串str1\n");
	}
	else
	printf("所查找的字符所在的地址为%p\n",p);
*/
/*
	p = strpbrk(str1,str2);//原型：char *strpbrk(char const *str, char const *group);
	if(p == NULL)
	{
		printf("str1中没有str2中的字符\n");
	}
	else
	printf("所查找的字符所在的地址为%p\n",p);
	printf("所查找的字符所在的地址为%p\n",&p);
*/
/*
	p = strstr(str1,str2);//原型：char *strstr(char *s1, char *s2);
	if(p == NULL)
	{
		printf("str1中没有str2中的字符\n");
	}
	else
	printf("所查找的字符所在的地址为%p\n",p);
	printf("所查找的字符所在的地址为%p\n",&p);
*/
/*
	q = strtok(NULL,str2);
	if(q == NULL)
	{
		printf("字符串内不存在更多的标记\n");
	}
*/
/*
	memset(q,0,strlen(str2));//原型：void *memset(void *s, int c, unsigned long n);

	printf("str1 = %s\n",str1);
	printf("str2 = %s\n",str2);
}

**/